package cn.JHai.dao;
import cn.JHai.domain.Favorite;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;

public interface FavoritesDao {
	// 保存收藏
	@Insert("insert into favorite (name,singer,album,gender,time,src,info,uid) values (#{name},#{singer},#{album},#{gender},#{time},#{src},#{info},#{uid})")
	public boolean save(Favorite favorite);
	// 查找所有
	@Select("select * from favorite")
	public ArrayList<Favorite> findAll();

	@Select("select * from favorite  where id=#{uid} ")
	public ArrayList<Favorite> findWithUid(int uid);

	@Select("select * from favorite  where id=#{mid} ")
	public Favorite find(String mid);

	@Select("SELECT  *  FROM  favorite  WHERE  name like CONCAT('%',#{name},'%') ")
	public ArrayList<Favorite> findfavorite(String name) ;

	@Delete("delete from favorite where id=#{mid} ")
	public boolean delete(String mid) ;

	@Update("update favorite set name=#{name},singer=#{album},gender=#{gender},time=#{favorite},src=#{src},info=#{info},uid=#{uid} where mid=#{mid}")
	public boolean update(Favorite favorite);
	}
